package com.life.smile.utils;

import java.util.List;
import java.util.Map;

import com.alibaba.fastjson.JSON;



/**
 * 
 * 文件名称: json 格式消息框
 * 内容摘要: 
 * 创 建 人: xuq
 * 创建日期: 2015-11-12
 * 修改记录1: // 修改历史记录，包括修改日期、修改者及修改内容
 *   修改日期：
 *   版 本 号：
 *   修 改 人：
 *   修改内容：
 * 修改记录2：…
 *
 */
public class ListJsonMessage {

	/**
	 * 00：表示成功； 
	 * 01：失败
	 * 09：程序异常
	 */
	private int draw ;
	
	private int recordsTotal ;// 表总记录条数
	private int recordsFiltered;// 条件过滤后的条数
	private Object  data= null;// 返回数据列表
	
	public ListJsonMessage(){}
	
	@SuppressWarnings({"rawtypes", "unchecked" })
	public ListJsonMessage(int draw,int recordsTotal,int recordsFiltered,Object data,int start){
		this.draw=draw;
		this.recordsTotal=recordsTotal;
		this.recordsFiltered=recordsFiltered;
		if(data!= null && data instanceof List){ //添加序号
			List list = (List) data;
			for(int i=0;i<list.size();i++){
				Map map = (Map)JSON.toJSON(list.get(i));
				map.put("xh", start+i+1);
			}
			this.data=data;
		} 
	}
	
	@Override
	public String toString() {
//		JsonMapper jsonMapper = new JsonMapper();
//		return jsonMapper.toJson(resultmap);
		return "";
	}
	
	public String toString(String postJson,String hisResultJson,Exception ex) {
		//OphiuxBaseService.addLog(postJson,hisResultJson, ex); // 添加日志
		//JsonMapper jsonMapper = new JsonMapper();
		//return jsonMapper.toJson(resultmap);
		return "";
	}


	 


	/**
	 * @return the draw
	 */
	public int getDraw() {
		return draw;
	}

	/**
	 * @param draw the draw to set
	 */
	public void setDraw(int draw) {
		this.draw = draw;
	}

	/**
	 * @return the recordsTotal
	 */
	public int getRecordsTotal() {
		return recordsTotal;
	}


	/**
	 * @param recordsTotal the recordsTotal to set
	 */
	public void setRecordsTotal(int recordsTotal) {
		this.recordsTotal = recordsTotal;
	}


	/**
	 * @return the recordsFiltered
	 */
	public int getRecordsFiltered() {
		return recordsFiltered;
	}


	/**
	 * @param recordsFiltered the recordsFiltered to set
	 */
	public void setRecordsFiltered(int recordsFiltered) {
		this.recordsFiltered = recordsFiltered;
	}


	/**
	 * @return the data
	 */
	public Object getData() {
		return data;
	}


	/**
	 * @param data the data to set
	 */
	public void setData(Object data) {
		this.data = data;
	}

	 

	
}
